#include<iostream>
#include<vector>
#include<list>
using namespace std;

class MyHashMap {
private:
	vector<list<pair<int, int>>> data;
	static const int base = 769;
	static int hash(int key) {
		return key % base;
	}
public:
	/** Initialize your data structure here. */
	MyHashMap() : data(base) {}

	/** value will always be non-negative. */
	void put(int key, int value) {
		int h = hash(key);
		for (auto it = data[h].begin(); it != data[h].end(); it++) {
			if ((*it).first == key) {
				(*it).second = value;
				return;
			}
		}
		data[h].push_back(make_pair(key, value));
	}

	/** Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key */
	int get(int key) {
		int h = hash(key);
		for (auto it = data[h].begin(); it != data[h].end(); it++) {
			if ((*it).first == key) {
				return (*it).second;
			}
		}
		return -1;
	}

	/** Removes the mapping of the specified value key if this map contains a mapping for the key */
	void remove(int key) {
		int h = hash(key);
		for (auto it = data[h].begin(); it != data[h].end(); it++) {
			if ((*it).first == key) {
				data[h].erase(it);
				return;
			}
		}
	}
};

class MyHashMap1 {
private:
	vector<list<pair<int, int>>> data;
	static const int base = 769;
	static int hashIndex(int key) {
		int index = key % base;
		return index;
	}
public:
	//MyHashMap1():data(base){}
	MyHashMap1() {
		data.resize(base);
	}

	void put(int key, int value) {
		int index = hashIndex(key);
		for (auto &&p : data[index]) {
			if (p.first == key) {
				p.second = value;
				return;
			}
		}
		data[index].push_back(make_pair(key, value));
	}

	int get(int key) {
		int index = hashIndex(key);
		for (auto &&p : data[index]) {
			if (p.first == key)
				return p.second;
		}
		return -1;
	}

	void remove(int key) {
		int index = hashIndex(key);
		for (auto it = data[index].begin();it!=data[index].end();++it) {
			if ((*it).first == key) {
				data[index].erase(it);
				return;
			}
		}
	}
};


void main() {
	//int key = 1, value = 0;
	//MyHashMap* obj = new MyHashMap();
	//obj->put(key, value);
	//int param_2 = obj->get(key);
	//obj->remove(key);
	MyHashMap1 map;
	map.put(1, 2);
	cout << "Done" << endl;
}